package com.zzc.study.enums;

import lombok.Getter;

import java.util.function.Function;


public enum TrafficLightEnum
{
    RED(s -> "红灯"),     // RED("1","红灯"),RED("1",函数),
    YELLOW(s -> "黄灯"),
    BULE(s -> {
        if(s.equals("A01")){
            return "手电筒";
        }else if (s.equals("A02")){
            return "鼠标";
        }else if (s.equals("A03")){
            return "剃须刀";
        }
        return "nothing";
    }),
    GEEEN(s -> "绿灯");

    //2 构造
    @Getter
    private final Function<String, String> trafficLight;

    TrafficLightEnum(Function<String, String> trafficLight)
    {
        this.trafficLight = trafficLight;
    }

    public static void main(String[] args)
    {
        System.out.println(TrafficLightEnum.BULE);
        System.out.println(TrafficLightEnum.BULE.getTrafficLight().apply("A02"));
    }
}








/*
    public static void main(String[] args)
    {
        System.out.println(TrafficLightEnum.YELLOW);
        System.out.println(TrafficLightEnum.YELLOW.getTrafficLight().apply("2"));
    }*/
